VERSION 5.00
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Object = "{8E27C92E-1264-101C-8A2F-040224009C02}#7.0#0"; "MSCAL.OCX"
Begin VB.Form frmViewTags 
   BackColor       =   &H00FFFFFF&
   Caption         =   "View/Add/Delete Pickups"
   ClientHeight    =   5595
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   9855
   Icon            =   "frmViewTags.frx":0000
   LinkTopic       =   "Form1"
   ScaleHeight     =   5595
   ScaleWidth      =   9855
   StartUpPosition =   1  'CenterOwner
   Begin MSACAL.Calendar Calendar1 
      Height          =   255
      Left            =   6600
      TabIndex        =   5
      TabStop         =   0   'False
      Top             =   2820
      Visible         =   0   'False
      Width           =   255
      _Version        =   524288
      _ExtentX        =   450
      _ExtentY        =   450
      _StockProps     =   1
      BackColor       =   16777215
      Year            =   2004
      Month           =   2
      Day             =   9
      DayLength       =   1
      MonthLength     =   2
      DayFontColor    =   0
      FirstDay        =   1
      GridCellEffect  =   1
      GridFontColor   =   10485760
      GridLinesColor  =   -2147483632
      ShowDateSelectors=   -1  'True
      ShowDays        =   -1  'True
      ShowHorizontalGrid=   -1  'True
      ShowTitle       =   0   'False
      ShowVerticalGrid=   -1  'True
      TitleFontColor  =   10485760
      ValueIsNull     =   -1  'True
      BeginProperty DayFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty GridFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty TitleFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Arial"
         Size            =   12.01
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
   End
   Begin VB.ComboBox cboStatus 
      Height          =   315
      ItemData        =   "frmViewTags.frx":030A
      Left            =   2400
      List            =   "frmViewTags.frx":0317
      TabIndex        =   10
      Top             =   4680
      Width           =   1635
   End
   Begin VB.ComboBox cboType 
      Height          =   315
      ItemData        =   "frmViewTags.frx":0335
      Left            =   2400
      List            =   "frmViewTags.frx":0342
      TabIndex        =   9
      Top             =   4320
      Width           =   1635
   End
   Begin VB.TextBox f1365 
      Height          =   315
      Left            =   6660
      TabIndex        =   6
      Top             =   4320
      Width           =   975
   End
   Begin VB.CommandButton cmdCancelPickup 
      Appearance      =   0  'Flat
      BackColor       =   &H00C0E0FF&
      Caption         =   "Cancel &Pickup"
      Height          =   315
      Left            =   4320
      MaskColor       =   &H0080C0FF&
      Style           =   1  'Graphical
      TabIndex        =   4
      Top             =   5160
      UseMaskColor    =   -1  'True
      Width           =   1215
   End
   Begin VB.CommandButton cmdADDTag 
      Appearance      =   0  'Flat
      BackColor       =   &H00C0E0FF&
      Caption         =   "&Add"
      Height          =   315
      Left            =   2400
      MaskColor       =   &H0080C0FF&
      Style           =   1  'Graphical
      TabIndex        =   3
      Top             =   5160
      UseMaskColor    =   -1  'True
      Width           =   1215
   End
   Begin VB.CommandButton cmdClose 
      Appearance      =   0  'Flat
      BackColor       =   &H00E0E0E0&
      Caption         =   "&Close"
      Height          =   315
      Left            =   6240
      MaskColor       =   &H0080C0FF&
      Style           =   1  'Graphical
      TabIndex        =   0
      Top             =   5160
      UseMaskColor    =   -1  'True
      Width           =   1215
   End
   Begin VB.Frame Frame1 
      BackColor       =   &H00FFFFFF&
      Caption         =   "Select Return Type and Scheduled Date"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000080FF&
      Height          =   4095
      Left            =   120
      TabIndex        =   1
      Top             =   120
      Width           =   9615
      Begin MSDataGridLib.DataGrid grdTags 
         Height          =   3495
         Left            =   240
         TabIndex        =   2
         TabStop         =   0   'False
         ToolTipText     =   "To Delete an Address, highlight a row and press the Delete button."
         Top             =   360
         Width           =   9135
         _ExtentX        =   16113
         _ExtentY        =   6165
         _Version        =   393216
         HeadLines       =   1
         RowHeight       =   15
         TabAction       =   2
         WrapCellPointer =   -1  'True
         AllowAddNew     =   -1  'True
         AllowDelete     =   -1  'True
         BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ColumnCount     =   2
         BeginProperty Column00 
            DataField       =   ""
            Caption         =   ""
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column01 
            DataField       =   ""
            Caption         =   ""
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         SplitCount      =   1
         BeginProperty Split0 
            BeginProperty Column00 
            EndProperty
            BeginProperty Column01 
            EndProperty
         EndProperty
      End
   End
   Begin VB.Label Label1 
      Alignment       =   1  'Right Justify
      BackColor       =   &H00FFFFFF&
      Caption         =   "Status:"
      Height          =   255
      Index           =   0
      Left            =   600
      TabIndex        =   11
      Top             =   4740
      Width           =   1635
   End
   Begin VB.Image Image1 
      Height          =   345
      Left            =   7740
      Picture         =   "frmViewTags.frx":0364
      Stretch         =   -1  'True
      Top             =   4320
      Width           =   345
   End
   Begin VB.Label Label1 
      Alignment       =   1  'Right Justify
      BackColor       =   &H00FFFFFF&
      Caption         =   "Pickup Date:"
      Height          =   255
      Index           =   44
      Left            =   5460
      TabIndex        =   8
      Top             =   4380
      Width           =   1095
   End
   Begin VB.Label Label1 
      Alignment       =   1  'Right Justify
      BackColor       =   &H00FFFFFF&
      Caption         =   "Pickup Type:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Index           =   4
      Left            =   600
      TabIndex        =   7
      Top             =   4380
      Width           =   1635
   End
End
Attribute VB_Name = "frmViewTags"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim m_rsTags As New ADODB.Recordset     'Module level recordset tied to grdCommodities

Private Sub cboStatus_Click()
    Call UpdateTagsGrid(cboType, cboStatus, f1365)
End Sub

Private Sub cboType_Click()
    Call UpdateTagsGrid(cboType, cboStatus, f1365)
End Sub

Private Sub cmdADDTag_Click()
    frmAddTags.Show vbModeless, Me
End Sub

Private Sub cmdClose_Click()
    Me.Hide
    frmShip.SetFocus
End Sub
'---------------------------------------------------------------------------------------
' Procedure : cmdCancelPickup_Click()
' DateTime  : 1/26/2006
' Purpose   : Send transaction to Cancel Pickup
'---------------------------------------------------------------------------------------
'
Private Sub cmdCancelPickup_Click()
    
     
    Call SendData(BuildCancelTagTrans(grdTags.Columns("Pickup #")))
    Call UpdateTagsGrid(cboType, cboStatus, f1365)

End Sub

Private Sub f1365_Change()
    
    If IsDate(f1365) Then
        If f1365 <> Date Then
            f1365.BackColor = &HC0E0FF
        Else
            f1365.BackColor = &HFFFFFF
        End If
        Call UpdateTagsGrid(cboType, cboStatus, f1365)
   End If

End Sub

Private Sub f1365_LostFocus()
    Call UpdateTagsGrid(cboType, cboStatus, f1365)
End Sub

'---------------------------------------------------------------------------------------
' Procedure : Form_Activate()
' DateTime  : 1/26/2006
' Purpose   : Call routine to load Tags into datagrid whenever the form is the
'             active form.
'---------------------------------------------------------------------------------------
'
Private Sub Form_Activate()
    On Error GoTo EH
    g_strErrorLocation = "frmIPD:Form_Activate"
        
    Call UpdateTagsGrid(cboType, cboStatus, f1365)
    cboType.SetFocus
    
    Exit Sub
EH:
    MsgBox Err.Description, vbCritical, g_strErrorLocation

End Sub
'---------------------------------------------------------------------------------------
' Procedure : Form_Deactivate()
' DateTime  : 1/26/2006
' Purpose   : Closes module level recordset and sets it to nothing.
'---------------------------------------------------------------------------------------
'
Private Sub Form_Deactivate()
    On Error GoTo EH
    g_strErrorLocation = "frmIPD:Form_Deactivate"
        
    If m_rsTags.State = adStateOpen Then m_rsTags.Close
    Set m_rsTags = Nothing
    
    Exit Sub
EH:
    MsgBox Err.Description, vbCritical, g_strErrorLocation

End Sub
'---------------------------------------------------------------------------------------
' Procedure : Form_KeyDown()
' DateTime  : 1/26/2006
' Purpose   : Enter key pressed sends a TAB to move to next field
'---------------------------------------------------------------------------------------
'
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If Not TypeOf Me.ActiveControl Is CommandButton Then
        If Shift = 0 And KeyCode = 13 Then
            SendKeys "{TAB}"
        End If
    End If
End Sub
'---------------------------------------------------------------------------------------
' Module    : Form_Load()
' DateTime  : 1/26/2006
' Author    : Chris Elwell
' Purpose   : Set initial values
'---------------------------------------------------------------------------------------
'
Private Sub Form_Load()
    
    f1365.Text = Date
    Calendar1.Today
    Calendar1.Height = 2295 'Ship date - Ship Tab
    Calendar1.Width = 3015
    cboType = "All"
    cboStatus = "Scheduled"
    
End Sub

Private Sub grdTags_Click()
    Call SetCancelPickupButton
End Sub

'---------------------------------------------------------------------------------------
' Module    : Image1_Click()
' DateTime  : 1/26/2006
' Author    : Chris Elwell
' Purpose   : Show the Pickup date calendar
'---------------------------------------------------------------------------------------
'
Private Sub Image1_Click()
    Calendar1.Visible = True
End Sub

'---------------------------------------------------------------------------------------
' Procedure : Calendar1_Click()
' DateTime  : 1/26/2006
' Purpose   : Puts date selected on calendar in Pickup date field and updates the Tags Grid.
'---------------------------------------------------------------------------------------
'
Private Sub Calendar1_DblClick()
    
    f1365.Text = Calendar1.Value
    Calendar1.Visible = False
    Call UpdateTagsGrid(cboType, cboStatus, f1365)

End Sub

'---------------------------------------------------------------------------------------
' Procedure : UpdateTagsGrid()
' DateTime  : 10/25/2004
' Purpose   : Update the IPD grid and set column headings
' Call from : Form_Activate, cmdDelete_Click
'---------------------------------------------------------------------------------------
'
Public Sub UpdateTagsGrid(ByVal strTagsType As String, ByVal strStatus As String, ByVal strPickupDate As String)
    Dim strQuery As String
    
    On Error GoTo EH
    g_strErrorLocation = "frmTags:UpdateTagsGrid"
    
    'Build query
    strQuery = "SELECT f1011, f29, f2210, f25, f11, f12, f13, f15, f16, f17, Type, Status FROM Tags WHERE f10 = " & SingleQuotes(g_str10)
    strQuery = strQuery & " And f1365 = " & SingleQuotes(Format(strPickupDate, "YYYYMMDD"))
    
    'Add Type
    Select Case strTagsType
        Case "Call Tag"
            strQuery = strQuery & " And Type = 'CT'"
        Case "Express Tag"
            strQuery = strQuery & " And Type = 'ET'"
    End Select
    
    'Add Status
    Select Case strStatus
        Case "Scheduled"
            strQuery = strQuery & " And Status = 'Scheduled'"
        Case "Canceled"
            strQuery = strQuery & " And Status = 'Canceled'"
    End Select
    
    'If already open, close recordset
    If m_rsTags.State = adStateOpen Then m_rsTags.Close
    'Execute query
    m_rsTags.Open strQuery, g_connFSMSClient, adOpenStatic, adLockOptimistic

    
    Set grdTags.DataSource = m_rsTags
    
    With grdTags
        .ClearFields
        .ReBind
        .Columns(0).Caption = "Pickup #"
        .Columns(1).Caption = "Trk #"
        .Columns(2).Caption = "RMA #"
        .Columns(3).Caption = "References"
        .Columns(4).Caption = "Company"
        .Columns(5).Caption = "Contact"
        .Columns(6).Caption = "Addr1"
        .Columns(7).Caption = "City"
        .Columns(8).Caption = "St"
        .Columns(9).Caption = "Zip"
        .Columns(10).Caption = "Type"
        .Columns(11).Caption = "Status"
    End With
    
    Call SetCancelPickupButton
    
Release:
    Set m_rsTags = Nothing
    Exit Sub
EH:
    MsgBox Err.Description, vbCritical, g_strErrorLocation
    Resume Release
     
End Sub

'---------------------------------------------------------------------------------------
' Module    : SetCancelPickupButton
' DateTime  : 1/26/2006
' Author    : Chris Elwell
' Purpose   : Enable/disable Cancel Pickup Button
' Call from :
'---------------------------------------------------------------------------------------
'
Public Sub SetCancelPickupButton()
    On Error GoTo EH
    
    'Only enable buttons if one row selected, cmdADDTag is enable (Winsock connected), Status is "Scheduled"
    'and the pickup date was not prior to today.
    With grdTags
        If .SelBookmarks.Count <> 1 Or cmdAddTag.Enabled = False Or _
            .Columns("Status") <> "Scheduled" Or DateDiff("d", Date, CDate(f1365)) < 0 Then
            
            cmdCancelPickup.Enabled = False
        Else
            cmdCancelPickup.Enabled = True
        End If
    End With
    
    Exit Sub
EH:
    'Do nothing
End Sub

